<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<html>
<head>
<title>Check-In Counter</title>

<style>
	.errors { color: #ff0000; }
</style>

</head>

<body>
	<h2>Check-in Counter: Seat Selection</h2>
    
    <h4>Ticket Information</h4>
    <table width="300" border="1">
    	<tr>
    		<td>Ticket Number:</td>
    		<td>${ticket.idTicket}</td>
    	</tr>
    	<tr>
    		<td>Travel Agency:</td>
    		<td>${ticket.travelAgency}</td>
    	</tr>
    </table>
    
	<h4>Passenger's Personal Data</h4>
        
  <table width="300" border="1">
      <tr>
	    <td>First Name:</td>
	    <td>${passenger.firstName}</td>
      </tr>
	  <tr>
	    <td>Last Name:</td>
	    <td>${passenger.lastName}</td>
      </tr>
	  <tr>
	    <td>Birthday:</td>
	    <td>${passenger.birthDate}</td>
      </tr>
	  <tr>
	    <td>Passport:</td>
	    <td>${passenger.passport}</td>
      </tr>
      <tr>
	    <td>Email: </td>
	    <td>${passenger.eMail}</td>
      </tr>
	  <tr>
	    <td>Phone: </td>
	    <td>${passenger.phone}</td>
      </tr>

</table>

<p>&nbsp;</p>

<img src="images/seats.JPG" alt="Seat" /> 

<p>&nbsp;</p>

<form:form name="seatselection" method="POST" action="seatselection.app">
<form:hidden path="idTicket" />

<h4>Please choose the seats for the following flights:</h4>
<table width="500">
		
	<c:forEach var="flightTicket" items="${flightTickets}" varStatus="rowCounter">
		<tr>
			<td>Flight with FlightTicket ${flightTicket.idFlightTicket}</td>
            <td>${flightRoutes[rowCounter.count-1].fromAirport}-${flightRoutes[rowCounter.count-1].toAirport}</td>
            <td>Seat:</td>
			<td>
			
			<form:select path="seatNumber${rowCounter.count}">
				<form:options items="${seatsList[rowCounter.count-1]}" itemValue="seat" itemLabel="seat" />			
			</form:select>
			
			<form:errors path="seatNumber${rowCounter.count}" cssClass="errors" /> </td>
		</tr>
		
	</c:forEach>
</table>

<h3>
  <input type="submit" value="Submit" />
</h3>
</form:form>
	
</body>
</html>